﻿using System;
using System.Web.Mvc;
using Framework.Domain;
using Shell.DomainDot;
using Framework.Poco;

namespace Framework.Mvc.Controllers
{
    public class AgencyGiftsManagerController : Controller
    {
        private AgencyGiftsContext context;

        public AgencyGiftsManagerController()
        {
            this.context = DomainDotFactory.Factory.Create<AgencyGiftsContext>();
        }


        [HttpGet]
        public ActionResult SetGifts(Agency currentAgency)
        {
            AgencyGiftViewModel model = new AgencyGiftViewModel(this.context.Gifts);
            model.AgencyIdentity = currentAgency.Id;
            model.AgencyGifts = this.context.GetGifts(currentAgency.Id);
            return View(model);
        }

        [HttpPost]
        public ActionResult SetGifts(AgencyGiftViewModel model)
        {
            context.SetGifts(model.AgencyIdentity, model.AgencyGifts);
            return View(model);
        }
    }
}